﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[AddComponentMenu("MyGame/EnemySpawn")]
public class EnemySpawn : MonoBehaviour {

    //敌人的Prefab
    public Transform m_enemy;
    //生成敌人间隔时间
    public  float m_timer= 3;

    protected Transform m_transform;

	// Use this for initialization
	void Start () {
        m_transform = this.transform;
	}
	
	// Update is called once per frame
	void Update () {
        m_timer -= Time.deltaTime;

        if (m_timer<=0)
        {
            m_timer = Random.value * 8.0f;
            if (m_timer<3)
            {
                m_timer = 3;

                Instantiate(m_enemy,new Vector3(Random.Range(-6,6),2,8),m_transform.rotation);
            }
        }
	}
    void OnDrawGizmos()
    {
        Gizmos.DrawIcon(transform.position,"Enemy.png",true);
    }
}
